﻿using System;
using System.Windows;
using System.Windows.Data;

namespace Common
{
   public class BooleanToVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
            {
                return Visibility.Collapsed;
            }
            else
            {
                bool bo = (bool)value;
                if (bo)
                {
                    return Visibility.Visible;
                }
                else
                {
                    return Visibility.Collapsed;
                }
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

   public class InverseBooleanToVisibilityConverter : IValueConverter
   {
       public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
       {
           if (value == null)
           {
               return Visibility.Collapsed;
           }
           else
           {
               bool bo = (bool)value;
               if (bo)
               {
                   return Visibility.Collapsed;
               }
               else
               {
                   return Visibility.Visible;
               }
           }
       }

       public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
       {
           throw new NotImplementedException();
       }
   }

   public class IsOnlineToFontWeightConverter : IValueConverter
   {
       public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
       {
           if (value == null)
           {
               return FontWeights.Normal;
           }
           else
           {
               bool bo = (bool)value;
               if (bo)
               {
                   return FontWeights.Bold;
               }
               else
               {
                   return FontWeights.Normal;
               }
           }
       }

       public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
       {
           throw new NotImplementedException();
       }
   }
}
